package com.ifnk.portaljava.hlyt.test;

import java.io.IOException;
import java.io.InputStream;

public class DecodingUtil {

	public static InputStream decoding(String tsharkcmd) {
		InputStream in = null;
		try {
			Process process = Runtime.getRuntime().exec(tsharkcmd);
			in = process.getInputStream();

			int i = 0;
			while (true) {
				if (in.available() <= 0) {
					i++;
					System.out.println(i);
					if (i > 20) {
						i = 0;
						break;
					}
					try {
						Thread.sleep(200);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					continue;
				} else if (in.available() > 0) {
					i = 0;
					break;
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return in;
	}
}
